import axios from 'axios';

axios.defaults.baseURL = 'http://localhost:8081'

export const createRepairPersonApi = (repairPerson) => {
    return axios.post('/carsys/repairPerson/create', repairPerson);
}

export const deleteUserApi = (userId) => {
    return axios.delete(`/carsys/user/deleteUser/${userId}`);
}

// 更新维修人员信息
export const updateRepairPersonApi = (repairPerson) => {
  return axios.put('/carsys/repairPerson/updateAllInfo', repairPerson);
};

// 更新用户信息
export const updateUserApi = (user) => {
  return axios.put('/carsys/user/updateUser', user);
};

// 获取所有维修人员的所有信息
export const getAllRepairPersonsApi = () => {
  return axios.get('/carsys/repairPerson/getAll');
};

// 获取所有用户的所有信息
export const getAllUsersApi = () => {
  return axios.get('/carsys/user/getAllUsers');
};

// 登录接口
export const loginApi = (user) => {
  return axios.post('/carsys/user/login', user);
};

// 获取用户信息（根据用户名）
export const getUserByUserNameApi = (username) => {
  return axios.get(`/carsys/user/getUserByUserName/${username}`);
};

export const registerApi = (user) =>{
    return axios.post('/carsys/user/addNewUser', user)
}

export const getRepairPersonApi =(userId)=>{
  return axios.get(`/carsys/repairPerson/user/${userId}`)
}

export const getRepairPersonDTOApi =(userId)=>{
  return axios.get(`/carsys/repairPerson/getRepairPersonByUserId/${userId}`)
}